package com.ning.ems.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Ning 242741154@qq.com
 * @date 2020/5/30 23:24
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    private static final String[] ORIGINS
            = new String[]{"GET", "POST", "PUT", "DELETE"};

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("http://localhost:8800",
                        "http://192.168.43.21:8800")
                .allowCredentials(true)
                .allowedMethods(ORIGINS)
                .maxAge(3600);
    }
}